@use 'sass:map';

// This function lets the user use an old variable name as long as the new
// variable's default hasn't been overridden.
@function prefer-new-var($old-var, $new-var, $map, $prop) {
  // If the new variable is still the default, and the old variable
  // does not equal the default (i.e., it's been overridden), return the
  // old variable. Otherwise return the new variable.
  @if $new-var == map.get($map, $prop) and $old-var != map.get($map, $prop) {
    @return $old-var;
  }

  @return $new-var;
}
